
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Jtail</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.4.0/js/bootstrap.min.js"></script>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.4.0/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="../static/css/login.css">
    <script src="../static/js/login.js"></script>
</head>
<body class="text-center bg-light h-100">

<form id="resetPwdForm" class="text-left mx-auto card p-4 w-100 p-2" autocomplete="off" onsubmit="return false" action="##" method="post">
    <h1 class="h4 mb-3 text-center">请重置Jtail密码</h1>

    <label for="initPassword">初始密码：</label>
    <div class="input-group">
        <input type="password" id="initPassword"  name="initPassword" class="form-control rounded-right" spellcheck="false" autocorrect="off" autocapitalize="off" required>

    </div>
    <label for="password">新密码：</label>
    <div class="input-group">
        <input type="password" id="password"  name="password" class="form-control rounded-right" spellcheck="false" autocorrect="off" autocapitalize="off" required>
        <button id="toggle-password" type="button" class="d-none"
                aria-label="Show password as plain text. Warning: this will display your password on the screen."></button>
    </div>
    <button onclick="resetPwd()" class="btn btn-lg btn-primary btn-block mt-3" id="loginBtn" >
        登录
    </button>
</form>


<script >

     function resetPwd() {
              $.ajax({
                  type: "POST",
                  dataType: "json",
                  url: "/resetPwd" ,
                  data: $('#resetPwdForm').serialize(),
                  success: function (result) {
                      if (result.code == 204) {
                          //重置成功
                          alert(result.msg);
                          location.href = "/login";
                      }else if(result.code == 205){
                           //初始密码错误
                          alert(result.msg);
                      }
                      ;
                  },
                  error : function() {
                      alert("异常！");
                  }
              });
     }




</script>

</body>
</html>
